package com.itheima.app.controller;

import com.itheima.app.manager.PeachBlossomManager;
import com.itheima.vo.SoundVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class PeachBlossomController {

    @Autowired
    private PeachBlossomManager peachBlossomManager;

    /**
     * 发送语音
     * @param soundFile
     * @return
     * @throws IOException
     */
    @PostMapping("/peachblossom")
    public ResponseEntity sendSound(MultipartFile soundFile) throws IOException {
        peachBlossomManager.sendBlossom(soundFile);
        return ResponseEntity.ok().body(null);
    }


    /**
     * 接受语音
     * @return
     */
    @GetMapping("/peachblossom")
    public ResponseEntity receiveSound(){
        SoundVo soundVo = peachBlossomManager.receiveSound();
        return ResponseEntity.ok().body(soundVo);
    }
}
